package com.yanqu.road.server.cmd.union.cross.honors;

import com.yanqu.road.entity.union.honors.UnionHistoryHonorsRecordData;
import com.yanqu.road.pb.union.cross.CrossUnionHonorsProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.union.honors.CrossUnionHonorsMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.string.StringUtils;

@Cmd(code = Protocol.C_UNION_HONORS_GET_UPLOAD, desc = "获得荣誉点")
public class CrossUnionGetHonorsUploadCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

        CrossUnionHonorsProto.CrossUnionGetHonorsUploadMsg uploadMsg = CrossUnionHonorsProto.CrossUnionGetHonorsUploadMsg.parseFrom(packet.getBytes());

        String unionUid = uploadMsg.getUnionUid();

        UnionHistoryHonorsRecordData recordData = new UnionHistoryHonorsRecordData();
        recordData.setActivityId(uploadMsg.getActivityId());
        recordData.setUnionUid(unionUid);
        recordData.setActivityChildType(uploadMsg.getRecord().getActivityChildType());
        recordData.setActivityType(uploadMsg.getRecord().getActivityType());
        recordData.setGetTime(uploadMsg.getRecord().getGetTime());
        recordData.setHonors(uploadMsg.getRecord().getHonors());
        recordData.setServerList(StringUtils.listToString(uploadMsg.getRecord().getServerListList(), ","));
        recordData.setRank(uploadMsg.getRecord().getRank());
        recordData.setInsertOption();
        CrossUnionHonorsMgr.addHonorsRecord(recordData);
    }

    @Override
    public void sendData() {

    }
}
